<template>
    <div class="qrcode-wrapper">
        <centerHeader/>

        <div class="qrcode-wrap">
            <div class="top-wrap">
                <div class="title_box">
                    <span class="title-01">我的顾客</span>
                    <i class="el-icon-arrow-down"></i>
                </div>
            </div>
            <div class="picker">
                <div class="timer_box">
                    <span>注册时间:</span>
                    <el-date-picker
                        v-model="startDate"
                        type="date"
                        placeholder="选择日期"
                        value-format="yyyy-MM-dd">
                    </el-date-picker>
                    <span>至</span>
                    <el-date-picker
                        v-model="endDate"
                        type="date"
                        placeholder="选择日期"
                        value-format="yyyy-MM-dd">
                    </el-date-picker>
                    <el-button type="danger"  size="mini" round @click="query_shop2">查询</el-button>
                </div>




                <div>
                    <div style="margin-top: 15px;" class="select_query">
                        <el-input placeholder="请输入内容" v-model="search" class="input-with-select">
                            <el-select v-model="searchtype" slot="prepend" placeholder="请选择">
                                <el-option label="姓名" value="name"></el-option>
                                <el-option label="电话" value="tel"></el-option>
                            </el-select>
                            <el-button slot="append" icon="el-icon-search" @click="query_shop2"></el-button>
                        </el-input>
                    </div>

                    <div class="shop_box">
                        <transition name="slide-fade" class="tran_box">
                            <div class="hotKey-wrap" v-if="isDetail">
                                <div class="shop_detail">
                                    <i class="el-icon-close shop_close" @click="close"></i>
                                    <div class="shop_name">{{item.store_name}}</div>
                                    <div class="shop_other_box">
                                        <div class="shop_other">
                                            <i class="el-icon-location-outline"></i> {{item.store_address}}
                                        </div>
                                        <div class="shop_other">
                                            <i class="el-icon-service"></i> {{item.contact}}
                                        </div>
                                        <div class="shop_other">
                                            <i class="el-icon-phone"></i>{{item.store_mobile}}
                                        </div>
                                        <div class="shop_other">
                                            <i class="el-icon-time"></i>注册时间:{{item.create_time |formatTime}}
                                        </div>
                                    </div>
                                    <div class="shop_price">
                                        <div>
                                            营业额:155555 元
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </transition>
                        <div class="shop_table_header">
                            <div class="th_one">姓名</div>
                            <div class="th_two">电话</div>
                           <!-- <div class="th_three">操作</div>-->
                        </div>
                        <ul class="shop_table_table" v-for="item in customerList" :key="item.store_uid">
                            <li >
                                <div class="td_one">
                                    <div class="td_item_one">
                                        <span class="td_name">{{item.username}}</span>
                                        <span v-if="item.set == 1">男</span>
                                        <span v-if="item.set == 2">女</span>

                                    </div>
                                </div>
                                <div class="td_two">
                                    <div class="td_item_one">{{item.mobile}}</div>

                                </div>
                              <!--  <div class="td_three">
                                    <div>
                                        <i class="el-icon-edit-outline"></i>
                                        <i class="el-icon-delete"></i>
                                    </div>
                                </div>-->
                            </li>
                        </ul>
                    </div>

                </div>
            </div>

        </div>
        <div class="submit-box">
            <button class="submit-btn" @click="query_shop">下拉加载更多</button>
        </div>
        <centerFooter/>
    </div>
</template>

<script type="text/ecmascript-6">
    import centerHeader from "@/views/center/components/centerHeader";
    import centerFooter from "@/views/center/components/centerFooter";
    import constant from "@/utils/constant.js";
    import searchPrdt from "../components/search";
    import { formatTime } from "@/utils/index.js";
    import moment from 'moment'
    // 引用API文件
    import http from "@/utils/http.js";

    import QRCode from "qrcode";

    export default {
        name: "qrcode",
        data() {
            return {
                user_info: {},
                startDate:"",
                endDate: '',
                isDetail:false,
                searchtype: 'name',
                search: '',
                customerList:[],
                shopDetail:{},
                item:{},
                p:0
            };
        },
        components: {
            centerHeader,
            centerFooter,
            searchPrdt,
        },
        methods: {

            query_shop(){
                let startD = new Date(this.startDate)
                let endD = new Date(this.endDate)
                if(startD.getTime() > endD.getTime()){
                    this.$message.warning('起始时间不能大于结束时间')
                    return false
                }
                this.p++;
                http.get(this, {
                    url: "ucenter/user_list",
                    data: {
                        token: localStorage.getItem("user_token"),
                        searchtype:this.searchtype,
                        startDate:this.startDate,
                        endDate:this.endDate,
                        search:this.search,
                        pagesize:5,
                        user_type:0,
                        p:this.p
                    },
                    dataType: "json",
                    success: function(data) {
                        if(data.status == 1){
                            let info = data.info;
                            if (this.p <= info.total_page) {
                                this.customerList = this.customerList.concat(info.list);
                            }

                        }else{
                            this.$message.error(data.info);
                        }

                    }
                })
            },
            // query_shop1(){
            //     this.p++;
            //     this.customerList = []
            //     http.get(this, {
            //         url: "ucenter/user_list",
            //         data: {
            //             token: localStorage.getItem("user_token"),
            //             searchtype:this.searchtype,
            //             startDate:this.startDate,
            //             endDate:this.endDate,
            //             search:this.search,
            //             pagesize:1,
            //             user_type:0,
            //             p:this.p
            //         },
            //         dataType: "json",
            //         success: function(data) {
            //             if(data.status == 1){
            //                 let info = data.info;

            //                 this.customerList = info.list;


            //             }else{
            //                 this.$message.error(data.info);
            //             }

            //         }
            //     })
            // },
            showDetail(id){
                http.get(this, {
                    url: "/store/detail",
                    data: {
                        token: localStorage.getItem("user_token"),
                        store_id:id
                    },
                    dataType: "json",
                    success: function(data) {
                        console.log(data)
                        if(data.status == 1){
                            this.item = data.info
                            this.isDetail = true
                        }else{
                            this.$message.error(data.info);
                        }

                    }
                })
            },
            close(){
                this.isDetail = false
            },
            query_shop2(){
                // this.searchtype = "";
                // this.search = "";
                this.p = 0;
                this.customerList = [];
                this.query_shop()
            }
        },
        created() {
            this.query_shop2()
        },
        watch: {
            $route() {
                console.log("监听");
                this.p = 0
                this.customerList = [];
                this.query_shop()
            }
        },
    };
</script>

<style scoped lang="scss">
    .qrcode-wrapper {
    }

    .top-wrap {
        $letHeight: 1.3rem;

        .title-txt {
            height: $letHeight;
            line-height: $letHeight;
            text-align: center;
            background-color: $c-white-light;

            span {
                color: $c-mainC;
                display: inline-block;
                line-height: $letHeight;
                vertical-align: middle;

                &.title-01 {
                    font-size: 0.38rem;
                }
            }
        }
    }

    .main-wrap {
        @extend .cmm-border;
    }

    .img-wrap {
        width: 5rem;
        height: 5rem;
        margin: 0.4rem auto;
        overflow: hidden;
        position: relative;
        padding: 0.22rem;

        .ad-img {
            @extend .cmm-translateXY;
            width: 100%;
        }
    }

    .qrcode-box {
        text-align: center;
        width: 100%;
        .qrcode-txt {
            width: 5.15rem;
            border-radius: 0.8rem;
            background-color: $c-danger;
            font-size: 0.52rem;
            color: $c-white-light;
            $letHeight: 0.6rem;
            height: $letHeight;
            line-height: $letHeight;
            text-align: center;
            margin: 0.48rem auto;
            display: inline-block;
            letter-spacing: 0.1rem;
            font-weight: bold;
        }
    }
    .title-txt-new{
        height:1rem;
        line-height:1rem;
        text-align: center;
        background-color: $c-white-light;
        font-size: 0.32rem;
    }
    .picker{
        padding:0 10px;
        border-top: 0.15rem solid #eeeeee;
        font-size: 0.3rem;
        .el-date-editor.el-input, .el-date-editor.el-input__inner{
            width:2.2rem;
        }
        /deep/.el-input__inner{
            font-size: 0.3rem;
        }
        /deep/.el-icon-search{
            font-size: 0.3rem;
        }
    }
    .timer_box{
        /deep/.el-input__inner{
            border: none;
        }
    }
    .shop_table_header{
        display: flex;
        line-height:1rem;
        padding:0 0.2rem;
        border-bottom:1px solid #eeeeee;
        &>div.th_one{
            flex:2
        }
        &>div.th_two{
            flex:1
        }
        &>div.th_three{
            flex:1
        }
    }
    .shop_table_table{
        &>li{
            padding:0.25rem 0.2rem;
            display: flex;
            border-bottom:0.013rem solid #eeeeee;
            &>div.td_one{
                flex:2;
                display: flex;
                align-items: center;
                &>div.td_item_one{
                    margin-bottom:0.2rem;
                }
                &>div.td_item_two{
                    line-height: 0.6rem;
                    &>span{
                        font-size: 0.08rem;

                    }

                }
            }
            &>div.td_two{
                flex:1;

                &>div.td_item_one{
                    margin-bottom:0.2rem;
                }
                &>div.td_item_two{
                    &>span{
                        font-size: 0.08rem;
                        margin-right:0.2rem;
                    }
                    .nickname{

                    }

                }
            }
            &>div.td_three{
                flex:1
            }
        }
    }
    .title_box{
        height: 0.9rem;
        line-height:0.9rem;
        font-size: 0.36rem;
        text-align: center;
    }
    .timer_box{
        height:0.8rem;
        line-height:0.8rem;
    }
    .hot-key {
        width: 100%;
        min-height: 6rem;
        span {
            display: inline-block;
            width: 30%;
            height: 0.5rem;
            line-height: 0.5rem;

            text-align: center;
            font-size: 0.32rem;
            margin: 0.1rem 0;
            margin-right: 0.12rem;
            background-color: $c-gray-dark;
            color: $c-mainC;
            border-radius: 0.06rem;
        }
    }
    .shop_detail{
        position: relative;
        .shop_name{
            height:1rem;
            line-height:1rem;
            padding:0 0.4rem;

            font-size: 0.3rem;
        }
        .shop_other_box{
            border-bottom:0.013333rem solid #eeeeee;
            border-top:0.013333rem solid #eeeeee;
        }
        .shop_other{
            height: 0.8rem;
            line-height:0.8rem;
            padding:0 0.4rem;
        }
        .shop_price{
            height:4rem;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 0.32rem;
            color:#c09a5b;
        }
    }
    .select_query{
        /deep/.el-input-group__prepend{
            width:1.6rem;
        }
        /deep/.el-input-group__append{
            width:1rem;
            text-align: center;
        }
        /deep/.input-with-select{
            height:0.8rem;
        }
        /deep/.el-input__inner{
            height:0.8rem;
        }
    }
    .shop_box{
        min-height:6rem;
        position: relative;
    }
    .slide-fade-enter-active {
        transition: all .3s ease;
    }
    .slide-fade-leave-active {
        transition: all .8s cubic-bezier(1.0, 0.5, 0.8, 1.0);
    }
    .slide-fade-enter, .slide-fade-leave-to
        /* .slide-fade-leave-active for below version 2.1.8 */ {
        transform: translateX(-100%);
        opacity: 0;
    }
    .shop_close{
        position: absolute;
        right: 0.3rem;
        top:0.32rem;
        font-size: 0.32rem;
    }
    .td_name{
        margin-right:0.3rem;
    }
</style>
